# -*- coding: utf-8 -*-

'''eof
name:店铺零售业状态
code:RetailFormat
tableName:
columnName:
groups:烟商
dependencies:BTM
type:常用指标
datasourceType:在线指标
description:
eof'''

import sys
import pandas as pd
import datetime

reload(sys)
sys.setdefaultencoding('utf-8')

def RetailFormat():
    null_type_list = ['', None, 'null', '/', 'Null', ' ']
    retail_format = ['商场', '烟酒商店', '超市', '便利店', '娱乐服务类' ,'食杂店', '其他类']
    try:
        BTM_ = BTM['data']
    except:
        return u'缺失值'
    try:
        if BTM_.has_key('indent') and BTM_['indent'] not in null_type_list \
                and BTM_.has_key('retailformat') and BTM_['retailformat'] not in null_type_list:
            if u'商场' in BTM_['retailformat']:
                return u'商场'
            elif u'烟酒' in BTM_['retailformat']:
                return u'烟酒商店'
            elif u'超市' in BTM_['retailformat']:
                return u'超市'
            elif u'便利' in BTM_['retailformat']:
                return u'便利店'
            elif u'娱乐' in BTM_['retailformat'] or u'服务' in BTM_['retailformat']:
                return u'娱乐服务类'
            elif u'食杂' in BTM_['retailformat']:
                return u'食杂店'
            elif u'其他' in BTM_['retailformat']:
                return u'其他类'
            else:
                return u'缺失值'
        else:
            return u'缺失值'
    except:
        return u'缺失值'

result = RetailFormat()